<template>
<view class="container">
	<view class="task-list detail-white">
		<view class="task-item border"
			@click="onTaskItem('profile')">
			<view class="task-item-content">
				<text>个人资料</text>
			</view>
			<view class="task-item-action">
				<uni-icons type="arrowright" size="16" color="#999999" />
			</view>
		</view>
		<view class="task-item border"
			@click="onTaskItem('notice')">
			<view class="task-item-content">
				<text>消息与提醒</text>
			</view>
			<view class="task-item-action">
				<uni-icons type="arrowright" size="16" color="#999999" />
			</view>
		</view>
		<view class="task-item"
			@click="onTaskItem('security')">
			<view class="task-item-content">
				<text>账户与安全</text>
			</view>
			<view class="task-item-action">
				<uni-icons type="arrowright" size="16" color="#999999" />
			</view>
		</view>
	</view>
	<view class="task-list sec-top detail-white">
		<view class="task-item border"
			@click="onTaskItem('download')">
			<view class="task-item-content">
				<text>下载与播放</text>
			</view>
			<view class="task-item-action">
				<uni-icons type="arrowright" size="16" color="#999999" />
			</view>
		</view>
		<view class="task-item"
			@click="onTaskItem('cache')">
			<view class="task-item-content">
				<text>清理缓存</text>
			</view>
			<view class="task-item-action">
				<uni-icons type="arrowright" size="16" color="#999999" />
			</view>
		</view>
	</view>
	<view class="task-list sec-top detail-white">
		<view class="task-item"
			@click="onTaskItem('about')">
			<view class="task-item-content">
				<text>关于我们</text>
			</view>
			<view class="task-item-action">
				<uni-icons type="arrowright" size="16" color="#999999" />
			</view>
		</view>
	</view>
	<!-- 退出 -->
	<view class="form-control-button padding">
		<button class="form-button"
			@click="onExit">退出</button>
	</view>
	<!-- 弹出框 -->
	<uni-popup id="cache"
		ref="cache"
		type="dialog">
		<uni-popup-dialog type="info"
			title="提示"
			content="清理缓存不影响已下载视频, 确认要清除吗？"
			@confirm="confirm" />
		</uni-popup-dialog>
	</uni-popup>
</view>
</template>

<script>
export default {
	data() {
		return {
			
		}
	},
	onShow() {
		const token = uni.getStorageSync('X-Auth-Token');
		if (!token) {
			uni.navigateTo({
				url: '/pages/login/login'
			});
		}
	},
	methods: {
		onExit() {
			uni.clearStorage();
			uni.navigateTo({
				url: '/pages/login/login?from=profile'
			});
		},
		confirm() {
			this.$refs.cache.close();
		},
		onTaskItem(type) {
			switch(type) {
				case 'cache':
					this.$refs.cache.open();
					break;
				default:
					uni.navigateTo({
						url: `/pages/setting/${ type }?from=setting`
					});
					break;
			}
		}
	}
}
</script>
